package com.sky.controller.user;

import com.sky.entity.Setmeal;
import com.sky.entity.SetmealDish;
import com.sky.result.Result;
import com.sky.service.SetmealService;
import com.sky.vo.DishItemVO;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.Past;
import java.util.List;

@RestController("userSetmealController")
@RequestMapping("/user/setmeal")
@Api(tags = "C端-套餐浏览接口")
@Slf4j
public class SetmealController {
    @Autowired
    private SetmealService setmealService;

    /**
     * 根据分类id查询套餐
     *
     * @param categoryId 分类id
     * @return R
     */
    @GetMapping("/list")
    public Result<List<Setmeal>> selectByCategoryId(Long categoryId) {
        List<Setmeal> setmeals = setmealService.selectByCategoryId(categoryId);
        return Result.success(setmeals);
    }

    /**
     * 根据套餐id查询包含的菜品
     * @param id 套餐id
     * @return R
     */
    @GetMapping("/dish/{id}")
    public Result<List<DishItemVO>> selectWithDishesByCategoryId(@PathVariable Long id) {
        List<DishItemVO> dishItemVOS = setmealService.selectWithDishesByCategoryId(id);
        return Result.success(dishItemVOS);
    }
}
